<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
   <title></title>
   <meta charset="UTF-8">
 </head>
  <body>
      <?php 
	if ($_SERVER["REQUEST_METHOD"] == "POST")
	{  	
		$condb = mysqli_connect("localhost","root","password","PROJECT");
		
		if(isset($_POST['courseId']) and isset($_POST['courseName']) and isset($_POST['startDate']) and isset($_POST['stopDate'])and isset($_SESSION['id']))
		{
		    $courseid= $_POST['courseId']; // sets variables to insert into database
		    $coursename= $_POST['courseName'];
		    $startdate = $_POST['startDate'];
		    $stopdate= $POST['stopDate'];
                    
                    
		    $id = $_SESSION['id'];// this variable is used to relate to specific user
                    
		    if(mysqli_connect_errno()) 
     		    {
      		    echo "connection failed " . mysqli_connect_error();
     		    }
                
		    $insert_1= "insert into COURSE (COURSE_ID, COURSE_NAME, START_DATE, STOP_DATE ) VALUES ('$courseid','$coursename','$startdate','$stopdate');"; //
		
		    if (!mysqli_query($condb,$insert_1))
 		    {
  		    die('Error: NO COURSE ' . mysqli_error($condb));
  		    }
                    
		
	       } 
	       header("location:availablecourses.php");
	}
	?>
  </body>
